//
//  AppDelegate.swift
//  Checklists
//
//  Created by JokerAtBaoFeng on 16/3/7.
//  Copyright © 2016年 baofeng. All rights reserved.
///

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    let dataModel = DataModel()

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        let navigationController = window?.rootViewController as! UINavigationController
        let controller = navigationController.viewControllers[0] as! AllListsViewController
        
        controller.dataModel = dataModel
    
        return true
    }

    func applicationDidEnterBackground(application: UIApplication) {
        saveData()
    }

    func applicationWillTerminate(application: UIApplication) {
        saveData()
    }
    
    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        print("received local notification")
    }
    func saveData(){
        dataModel.saveChecklists()
    }
}

